import request from '/@/utils/request';

/**
 * 获取后端动态路由菜单(admin)

 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */

export function saveMenu(keyValue: String, params: object) {
    return request({
        url: '/api/system/menu/save?keyValue=' + keyValue,
        method: 'post',
        data: params,
    });
}

export function getMenuByAuth() {
    return request({
        url: '/api/system/menu/query/checkTree',
        method: 'get'
    });

}

export function getAuthBtnByPath(url: string) {
    return request({
        url: `/api//system/menu/query/authButtonColumnList?url=${url}`,
        method: 'get'
    });

}

export function getBtnByAuth(objectId: string) {
    return request({
        url: `/api/authorize/module/query/auth/${objectId}`,
        method: 'get'
    });

}

export function useMenuApi() {
    return {
        getMenuAdmin: (params?: object) => {
            return request({
                url: '/gitee/lyt-top/vue-next-admin-images/raw/master/menu/adminMenu.json',
                method: 'get',
                params,
            });
        },
        getMenuTest: (params?: object) => {
            return request({
                url: '/gitee/lyt-top/vue-next-admin-images/raw/master/menu/testMenu.json',
                method: 'get',
                params,
            });
        },
    };
}
/**
 * 获取后端动态路由菜单(admin)

 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */
export function getMenuList(params?: object) {
    return request({
        url: '/api/system/menu/query/tree',
        method: 'get',
        params,
    });
}

export function getMenuEntity(menuId?: String) {
    return request({
        url: '/api/system/menu/query/'+menuId,
        method: 'get',

    });
}

export function addMenuData( params: object) {
    return request({
        url: '/api/system/menu',
        method: 'post',
        data: params,
    });
}

export function updataMenuData( params: object) {
    return request({
        url: '/api/system/menu',
        method: 'put',
        data: params,
    });
}


export function deleteMenu(menuId: String) {
    return request({
        url: '/api/system/menu/delect/' + menuId,
        method: 'delete',
    });
}

export function getMenuDtoListByMenuId(menuId?: String) {
    return request({
        url: '/api/system/menu/query/systemMenuDto/'+menuId,
        method: 'get',

    });
}

export function getMenuButtonEntity(buttonId?: String) {
    return request({
        url: '/api/system/menu/button/query/entity/'+buttonId,
        method: 'get',

    });
}

export function deleteMenuButtonEntity(buttonId?: String) {
    return request({
        url: '/api/system/menu/button/delete/'+buttonId,
        method: 'delete',

    });
}

export function getMenuAdmin(params?: object) {
    return request({
        url: '/gitee/lyt-top/vue-next-admin-images/raw/master/menu/adminMenu.json',
        method: 'get',
        params,
    });
}

/**
 * 获取后端动态路由菜单(test)

 * @param params 要传的参数值，非必传
 * @returns 返回接口数据
 */
export function getMenuTest(params?: object) {
    return request({
        url: '/gitee/lyt-top/vue-next-admin-images/raw/master/menu/testMenu.json',
        method: 'get',
        params,
    });
}
